package messages;

public class TuneData extends MessageHeader {

	private short	mpbHd;
	private byte	rec_size;
	private byte	mpb_len;
	private short[]	mpbData;

	/* ---------------------------------------------------------------- CONSTRUCTORS */

	public TuneData( short _destID , short _srcID , short _mpbHd , byte _rec_size , byte _mpb_len ,
			short[] _mpbData ) {
		super( _destID , _srcID );
		concatMpbHd( _mpbHd );
		concatRecSize( _rec_size );
		concatMpbLen( _mpb_len );
		concatMpbData( _mpbData );
	}

	/* ---------------------------------------------------------------- PRIVATE */

	private void concatMpbHd( short _mpbHd ) {
		this.mpbHd = _mpbHd;
		this.incrementLength( (short) 2 );
	}

	private void concatRecSize( byte _recSize ) {
		this.rec_size = _recSize;
		this.incrementLength( (short) 1 );
	}

	private void concatMpbLen( byte _mpbLen ) {
		this.mpb_len = _mpbLen;
		this.incrementLength( (short) 1 );
	}

	private void concatMpbData( short[] _mpbData ) {
		this.mpbData = _mpbData;
		if ( _mpbData != null ) this.incrementLength( (short) ( _mpbData.length * 2 ) );

	}

	/* ---------------------------------------------------------------- PUBLIC */

	public short getMpbHd( ) {
		return mpbHd;
	}

	public void setMpbHd( short mpbHd ) {
		this.mpbHd = mpbHd;
	}

	public byte getRec_size( ) {
		return rec_size;
	}

	public void setRec_size( byte recSize ) {
		rec_size = recSize;
	}

	public byte getMpb_len( ) {
		return mpb_len;
	}

	public void setMpb_len( byte mpbLen ) {
		mpb_len = mpbLen;
	}

	public short[] getMpbData( ) {
		return mpbData;
	}

	public void setMpbData( short[] mpbData ) {
		this.mpbData = mpbData;
	}

	@Override
	public String toString( ) {
		StringBuilder stb = new StringBuilder( );
		stb.append( " [ TUNE_DATA ] = " + super.toString( ) + " | <MpbHd=" + this.mpbHd
				+ "> | <RecSize=" + this.rec_size + ".MpbLen=" + this.mpb_len + "> | " );

		if ( this.mpbData == null )
			stb.append( " <null> " );
		else {
			stb.append( " [[ " );
			for ( int i = 0 ; i < this.mpbData.length ; i++ ) {
				stb.append( " <MpbData=" + this.mpbData[i] + "> " );
			}
			stb.append( " ]] " );
		}

		return stb.toString( );

	}
}
